<template>
<div>
  <h1>用户展示</h1>
  <el-table
    :data="tableData"
    style="width: 100%">

    <el-table-column
      label="姓名"
      width="100">
      <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.username }}</el-tag>
          </div>
      </template>
    </el-table-column>

    <el-table-column
      label="邮箱"
      width="240">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.email }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="手机号"
      width="240">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.phone }}</span>
      </template>
    </el-table-column>

    <el-table-column
      label="权限"
      width="240">
      <template slot-scope="scope">
        <span style="margin-left: 10px" v-if="scope.row.type==1">
            收货
        </span>
        <span style="margin-left: 10px" v-if="scope.row.type==2">
            发货</span>
        <span style="margin-left: 10px" v-if="scope.row.type==3">
            收货+发货</span>
        <span style="margin-left: 10px" v-if="scope.row.type==4">
            客服</span>
        <span style="margin-left: 10px" v-if="scope.row.type==5">
            管理员</span>
      </template>
    </el-table-column>

    <el-table-column
      label="状态"
      width="240">
      <template slot-scope="scope">
        <span style="margin-left: 10px" v-if="scope.row.auditing==0">
            待审核
        </span>
        <span style="margin-left: 10px" v-if="scope.row.auditing==1">
            审核通过</span>
        <span style="margin-left: 10px" v-if="scope.row.auditing==2">
            审核失败</span>
      </template>
    </el-table-column>


    <el-table-column label="操作">
      <template slot-scope="scope">
        <span v-if="scope.row.auditing==0">
          <el-button
          size="mini"
          type="danger"
          @click="via(scope.row.id)">审核通过</el-button>
        </span>
        <el-button
          size="mini"
          type="danger"
          @click="del(scope.row.id)">存档</el-button>
          
      </template>
    </el-table-column>
    
  </el-table>
  
</div>  
</template>
<style>

</style>
<script>
import { show_post,audit_post,del_post } from './axios_api/api';
  export default {
    data() {
      return {
        tableData: [],
      }
    },
    mounted(){
      this.getuser();
    },
    methods: {
      via(id){
        var data = {id:id}
        audit_post(data).then(resp=>{
          this.$Message(resp.message)
        })
      },
      del(id){
        var data = {id:id}
        del_post(data).then(resp=>{
          this.$Message(resp.message)
        })
      },
      getuser(){
          var uid = localStorage.getItem('uid')
          var data = {uid:uid}
          show_post(data).then(resp=>{
              this.tableData = resp.userlist;
              console.log(this.userlist)
          })
      },
    }
  }
</script>